package com.example.sneakerappforme1105.bean;

import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.PrimaryKey;

import java.io.Serializable;

@Entity(tableName = "tb_cartItem",
        foreignKeys = {
//            @ForeignKey(
//                    entity = Cart.class,
//                    parentColumns = "cartId",
//                    childColumns = "cartId",
//                    onDelete = ForeignKey.CASCADE
//            ),
                @ForeignKey(
                        entity = Goods.class,
                        parentColumns = "goodsId",
                        childColumns = "goodsId",
                        onDelete = ForeignKey.CASCADE
                )
        }
)
public class CartItem implements Serializable { // 多对多的关系，购物车和商品的多对多关系
    @PrimaryKey(autoGenerate = true) // 该字段是自增主键
    @NonNull
    private long cartItemId;
    private long cartId; // 外键  一对多
    private long goodsId; // 外键   一对多
    private int num; // 商品数量   一项商品
    private double price; // 单项商品总价  一项商品的价格
    private String size; // 鞋码数,衣服尺寸
    private Integer isChecked; // 新增字段 0 ,1

    public Integer getIsChecked() {
        return isChecked;
    }

    public void setIsChecked(Integer isChecked) {
        this.isChecked = isChecked;
    }

    public CartItem(long cartId, long goodsId, int num, double price, String size, Integer isChecked) {
        this.cartId = cartId;
        this.goodsId = goodsId;
        this.num = num;
        this.price = price;
        this.size = size;
        this.isChecked = isChecked;
    }

    public CartItem(){

    }

    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

    public Long getCartItemId() {
        return cartItemId;
    }

    public void setCartItemId(long cartItemId) {
        this.cartItemId = cartItemId;
    }

    public long getCartId() {
        return cartId;
    }

    public void setCartId(long cartId) {
        this.cartId = cartId;
    }

    public long getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(long goodsId) {
        this.goodsId = goodsId;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }
}
